<?php

class DomainDefinition
{

  protected $entities = array();

  public function addEntity($name, EntityDefinition $def)
  {
    $this->entities[$name] = $def;
  }

  public function getEntity($name)
  {
    if (! $this->hasEntity($name)) {
      throw new DomainDefinitionException("Entity not found in domain: <b>$name</b>");
    }
    
    return $this->entities[$name];
  }

  public function hasEntity($name)
  {
    return isset($this->entities[$name]);
  }

  /**
   *
   * @return array
   */
  public function getDefinition()
  {
    $def = array();

    if (! empty($this->entities)) {
      foreach ($this->entities as $name => $entity) {
        $def[$name] = $entity->getDefinition();
      }
    }

    return $def;
  }

}

?>